package com.og.backingbean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;

import org.hibernate.validator.constraints.NotEmpty;

/**
 * @author Renaud DIANA
 *
 */
@Entity
@NamedQueries({@NamedQuery(name = "Ticket.findAll", query = "SELECT t FROM Ticket t ORDER BY t.idTicket ASC")})
public class Ticket implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@NotNull
	@NotEmpty
	@Column(nullable = false, length = 50)
	private String idTicket;
	@NotNull
	@Past
	@Column(nullable = false)
	@Temporal(TemporalType.DATE)
	private Date startDate;
	@Past
	@Temporal(TemporalType.DATE)
	private Date endDate;
	private String clientComments;
	private String ourComments;
	@NotNull
	@ManyToOne
	@JoinColumn(nullable = false)
	private Contract contract;
	@NotNull
	@ManyToOne
	@JoinColumn(nullable = false)
	private Status status;
	@NotNull
	@ManyToOne	
	@JoinColumn(nullable = false)
	private Bug bug;
	@ManyToOne
	private Solution solution;
	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(nullable = true)
	private Ticket ticket;
	
	/**
	 * Default constructor
	 */
	public Ticket() {
		// TODO Auto-generated constructor stub
	}

	public String getIdTicket() {
		return idTicket;
	}

	public void setIdTicket(String idTicket) {
		this.idTicket = idTicket;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public String getClientComments() {
		return clientComments;
	}

	public void setClientComments(String clientComments) {
		this.clientComments = clientComments;
	}

	public String getOurComments() {
		return ourComments;
	}

	public void setOurComments(String ourComments) {
		this.ourComments = ourComments;
	}

	public Contract getContract() {
		return contract;
	}

	public void setContract(Contract contract) {
		this.contract = contract;
	}

	public Status getStatus() {
		return status;
	}

	public void setStatus(Status status) {
		this.status = status;
	}

	public Bug getBug() {
		return bug;
	}

	public void setBug(Bug bug) {
		this.bug = bug;
	}

	public Solution getSolution() {
		return solution;
	}

	public void setSolution(Solution solution) {
		this.solution = solution;
	}

	public Ticket getTicket() {
		return ticket;
	}

	public void setTicket(Ticket ticket) {
		this.ticket = ticket;
	}

}
